home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Toolkit / Songbird 0.1 / Songbird_0_1_0.exe / chrome / content / songbird_interfaces.js < prev    next >
Text File  |  2006-02-07  |  3KB  |  96 lines

  1. /*
  2. //
  3. // BEGIN SONGBIRD GPL
  4. // 
  5. // This file is part of the Songbird web player.
  6. //
  7. // Copyright⌐ 2006 Pioneers of the Inevitable LLC
  8. // http://songbirdnest.com
  9. // 
  10. // This file may be licensed under the terms of of the
  11. // GNU General Public License Version 2 (the ôGPLö).
  12. // 
  13. // Software distributed under the License is distributed 
  14. // on an ôAS ISö basis, WITHOUT WARRANTY OF ANY KIND, either 
  15. // express or implied. See the GPL for the specific language 
  16. // governing rights and limitations.
  17. //
  18. // You should have received a copy of the GPL along with this 
  19. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  20. // or write to the Free Software Foundation, Inc., 
  21. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. // 
  23. // END SONGBIRD GPL
  24. //
  25.  */
  26.  
  27. //
  28. // Formal constructors to get interfaces because I'm lazy.
  29. //
  30.  
  31. const sbIDatabaseQuery = new Components.Constructor("@songbird.org/Songbird/DatabaseQuery;1", "sbIDatabaseQuery");
  32.  
  33. const sbIPlaylistsource = new Components.Constructor("@mozilla.org/rdf/datasource;1?name=playlist", "sbIPlaylistsource");
  34.  
  35. const sbIMediaLibrary = new Components.Constructor("@songbird.org/Songbird/MediaLibrary;1", "sbIMediaLibrary");
  36.  
  37. const sbIPlaylistManager = new Components.Constructor("@songbird.org/Songbird/PlaylistManager;1", "sbIPlaylistManager");
  38. const sbIPlaylist = new Components.Constructor("@songbird.org/Songbird/Playlist;1", "sbIPlaylist");
  39. const sbISimplePlaylist = new Components.Constructor("@songbird.org/Songbird/SimplePlaylist;1", "sbISimplePlaylist");
  40. const sbIDynamicPlaylist = new Components.Constructor("@songbird.org/Songbird/DynamicPlaylist;1", "sbIDynamicPlaylist");
  41. const sbISmartPlaylist = new Components.Constructor("@songbird.org/Songbird/SmartPlaylist;1", "sbISmartPlaylist");
  42.  
  43. const sbIPlaylistReaderManager = new Components.Constructor("@songbird.org/Songbird/PlaylistReaderManager;1", "sbIPlaylistReaderManager");
  44. const sbIPlaylistReaderListener = new Components.Constructor("@songbird.org/Songbird/PlaylistReaderListener;1", "sbIPlaylistReaderListener");
  45.  
  46. const sbIMediaScan = new Components.Constructor("@songbird.org/Songbird/MediaScan;1", "sbIMediaScan");
  47. const sbIMediaScanQuery = new Components.Constructor("@songbird.org/Songbird/MediaScanQuery;1", "sbIMediaScanQuery");
  48.  
  49. //
  50. // SBBindInterface - take an object and make it a wrapper of the given type. (doesn't crash)
  51. //
  52. function SBBindInterface( obj, contract_id, cid, as_service )
  53. {
  54.   try
  55.   {
  56.     if ( !obj )
  57.     {
  58.       var new_obj = {};
  59.       obj = new_obj;
  60.     }
  61.     // First, get the factory by contract ID
  62.     obj.m_Instance = Components.classes[ contract_id ];
  63.     if ( obj.m_Instance )
  64.     {
  65.       // Massage it into an actual object of our type
  66.       if ( as_service )
  67.         obj.m_Instance = obj.m_Instance.getService();
  68.       else
  69.         obj.m_Instance = obj.m_Instance.createInstance();
  70.       obj.m_Instance = obj.m_Instance.QueryInterface( cid );
  71.  
  72.       // Then attach the methods
  73.       if ( obj.m_Instance )
  74.       {
  75.         for ( var i in obj.m_Instance )
  76.         {
  77.           obj[ i ] = obj.m_Instance[ i ];
  78.         }
  79.       }
  80.       else
  81.       {
  82.         alert( "Load Failed - " + contract_id );
  83.       }
  84.     }
  85.     else
  86.     {
  87.       alert( "Load Failed - " + contract_id );
  88.     }
  89.   }
  90.   catch ( err )
  91.   {
  92.     alert( err );
  93.   }
  94.   return obj;
  95. }
  96.